<include file="public/min-header"/>
<div class="wrapper">
    <include file="public/breadcrumb"/>
    <!-- Main content -->
    <section class="content">
        <!-- Main content -->
        <div class="container-fluid">
            <div class="pull-right">
                <a class="btn btn-primary" href="{:U('Plugin/add_shipping')}">添加物流</a>
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i>物流列表</h3>
                </div>
                <div class="table-responsive">
                    <table class="table table-bordered table-hover">
                        <thead>
                        <tr>
                            <td class="text-left">物流名称</td>
                            <td class="text-left">官方电话</td>
                            <td class="text-left">操作</td>
                        </tr>
                        </thead>
                        <tbody>
                        <volist name="shipping" id="p">
                            <tr>
                                <td class="text-left">{$p.name}</td>
                                <td class="text-left">{$p.desc}</td>
                                <td class="text-left">
                                    <if condition="$p['status'] eq 1">
                                    <a onclick="installPlugin('{$p.type}','{$p.code}',0)" href="#" class="btn btn-danger" role="button">卸载</a>
                                    <a href="{:U('Plugin/edit_logistics',array('type'=>$p['type'],'code'=>$p['code']))}" class="btn btn-primary" role="button">配置</a>
                                    <a href="{:U('Plugin/shipping_print',array('type'=>'shipping','code'=>$p['code']))}" class="btn btn-primary" role="button">模板编辑</a>
                                    <else/>
                                    <a onclick="installPlugin('{$p.type}','{$p.code}',1)" href="#" class="btn btn-primary" role="button">一键安装</a>
                                    <a onclick="del_shipping('{$p.code}')" href="#" class="btn btn-danger" role="button"><i class="fa fa-trash-o"></i></a>
                                    </if>
                                </td>
                            </tr>
                        </volist>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </section>
</div>
<script>
    // 删除物流
    function del_shipping(code){
        layer.confirm('确定要删除吗?', function() {
            $.ajax({
                type: "POST",
                url: "{:U('Plugin/del_shipping')}",//+tab,
                dataType: "json",
                data: {code: code},
                success: function (data) {
                    layer.alert(data.msg, function (index) {
                        layer.close(index);
                        location.reload();
                    });
                }
            });
        })
    }
    //插件安装(卸载)
    function installPlugin(type,code,type2){
        var url = '/index.php?m=mingteng&c=Plugin&a=install&type='+type+'&code='+code+'&install='+type2;
        $.get(url,function(data){
            layer.alert(data.msg);
            if(data.status == 1){setTimeout(function(){
                window.location.href='/index.php?m=mingteng&c=Plugin&a=logistics&type='+type;
            },2000);}
        })
    }
</script>
</body>
</html>